package com.letfox.finance.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.letfox.common.model.ResultResponse;
import com.letfox.finance.model.ad.ADOutcomeServingDetail;
import com.letfox.finance.model.ad.FIMFinADServing;
import com.letfox.finance.service.ADPlanFINIncomeService;
import com.letfox.finance.service.ad.ADOutcomeServingDetaiService;
import com.letfox.finance.service.ad.FIMFinADServingService;

@Service
public class ADPlanFINIncomeServiceImpl implements ADPlanFINIncomeService{
	
	@Autowired
	private FIMFinADServingService fimFinADServingService;
	@Autowired
	private ADOutcomeServingDetaiService daOutcomeServingDetaiService;

	
	@Override
	public ResultResponse selectPlanFim(String planId, String startCreateTime,
			String endCreateTime) {
		ResultResponse resultResponse=new ResultResponse();
		Map<String, String> map=new HashMap<String, String>();
		map.put("planId", planId);
		map.put("startCreateTime", startCreateTime==""?null:startCreateTime);
		map.put("endCreateTime", endCreateTime==""?null:endCreateTime);
		FIMFinADServing fimFinADServing=fimFinADServingService.selectADFin(map);
		resultResponse.setData(fimFinADServing);
		return resultResponse;
	}

	@Override
	public ResultResponse addPlanFim(String adServingId, String finOutcomeId) {
		ResultResponse resultResponse=new ResultResponse();
		ADOutcomeServingDetail adOutcomeServingDetail=new ADOutcomeServingDetail();
		//广告明细ID
		adOutcomeServingDetail.setAdServingId(adServingId);
		//出账明细ID
		adOutcomeServingDetail.setFinOutcomeId(finOutcomeId);
		//创建时间
		adOutcomeServingDetail.setCreateTime(new Date());
		//修改时间
		adOutcomeServingDetail.setUpdateTime(new Date());
		//创建人
		adOutcomeServingDetail.setCreateBy("system");
		//修改人
		adOutcomeServingDetail.setUpdateBy("system");
		//是否有效数据
		adOutcomeServingDetail.setDel("0");
		int i=daOutcomeServingDetaiService.insert(adOutcomeServingDetail);
		resultResponse.setData(i);
		return resultResponse;
	}

}
